<#assign ctx = request.contextPath />
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>商品购物车</title>

	<link rel="stylesheet" href="${ctx}/css/common.css" />
	<link rel="stylesheet" type="text/css" href="${ctx}/css/shop_cart.css">
	<script type="text/javascript" src="${ctx}/js/jquery-1.11.0.js" ></script>
	<script type="text/javascript" src="${ctx}/js/common.js" ></script>
	<script type="text/javascript" src="${ctx}/js/shopCar.js" ></script>
	<script type="text/javascript" src="${ctx}/js/pro_details.js" ></script>
	<script type="text/javascript" src="${ctx}/js/shop_car.js" ></script>
	<script>
	$(function(){
		$("#btnSubmit").click(function(){
			
			alert("------")
			var imgs = $("img[id^='input_']");
			if(imgs.length > 0){
				var ids = new Array();
				$.each(imgs,function(index){
					ids[index] = this.id.replace("input_","");
					//发送请求
					location.href = "${ctx}/customer/order/toSubmitOrder?ids="+ids;
				})
			}else{
				alert("请至少勾选一条记录才能提交订单!");
			}
			
		})
		
		$("#input_").click(function(){
			alert("--------");
		})
		
	})
	
	
	
	
	function updateCar(id,tag){
		var buyNum = $("#buyNum").val();
		if(tag==1){
			if(buyNum>1){
				buyNum--;
			}
		}else{
			if(buyNum<5){
				buyNum++;
			}
		}
		//发送ajax请求,修改购物车
		$.post("${ctx}/customer/shopCar/updateShopCar",
				{"goodsId":id,"buyNum":buyNum},function(data){
			if(data.status=="success"){
				//重新设置val()值
				$("#buyNum").val(buyNum);
				//通过ajax获取购物车数量
				$.post("${ctx}/customer/shopCar/getAjaxCount",function(data){
					console.log(data.count);
					$("#shopNum").text(data.count);
				})
			}
		})
		
	}
	
	</script>
	
</head>
<body>
	<div id="header">
		<!-- top -->
		<#include "common/top.html"/>
		<!-- top end -->
		<!-- search -->
		<#include "common/search.html"/>
		<!-- search end -->
		<div class="header_bottom">
			<div class="container">
				
				<div class="all">
					<a href="javascript:;">全部商品</a>
					<ul >				
						<li><a href="shop_list.html">清洁</a></li>
						<li><a href="shop_list.html">保湿</a></li>
						<li><a href="shop_list.html">滋润</a></li>
						<li><a href="shop_list.html">清凉舒爽</a></li>
						<li><a href="shop_list.html">补水</a></li>
						<li><a href="shop_list.html">清爽</a></li>
						<li><a href="shop_list.html">深层清洁</a></li>
						<li><a href="shop_list.html">舒缓肌肤</a></li>
					</ul>
				</div>
				<div class="nav">
					<ul>
						<li>
							<a href="shop_list.html">去屑</a>
							
						</li>
						<li>
							<a href="shop_list.html">健身</a>
									
						</li>
						<li>
							<a href="shop_list.html">花味</a>
							
						</li>
						<li>
							<a href="shop_list.html">磨砂</a>
							
						</li>
						<li>
							<a href="shop_list.html">沐浴露</a>
							
						</li>
						<li>
							<a href="shop_list.html">牛奶味</a>
							
						</li>
						<li>
							<a href="shop_list.html">香皂</a>
							
						</li>
						<li>
							<a href="shop_list.html">驱蚊止痒</a>
						
						</li>
						<li>
							<a href="shop_list.html">泡澡</a>		
						</li>					
						<li>
							<a href="shop_list.html">沐浴套装</a>
						</li>
						<li>
							<a href="shop_list.html">果味</a>
						</li>
					</ul>
				</div>
			</div>
		</div>					
	</div>
	<div id="content">
		<div class="container">
			<div class="big_title clear">
				<ul>
					<li>
						<a href="#"><span>&radic;</span>查看购物车</a>
						<span></span>
						
					</li>
					<li>
						<a href="#"><span>2</span>确认订单信息</a>
						<span></span>
						
					</li>
					<li>
						<a href="#"><span >3</span>成功提交订单</a>
						
					</li>
				</ul>
			</div>
			<div class="small_title clear">
				<ul>
					<li class="on"><a href="#" >全部商品&nbsp;<span class="badge">2</span></a></li>
					<li><a href="#">降价物品&nbsp;0</a></li>
					<li><a href="#">库存紧张&nbsp;0</a></li>
					<li><span>已选物品（不含运费）</span></li>
					<li><a href="confirm.html">结算</a></li>
				</ul>
			</div>
			<div class="details clear">
				<ul>
					<li>
						<a href="javascript:void(0);" id="checkAll"><img src="${ctx}/images/shop_car01.png" alt="0" />全选</a>
					</li>
					<li><span>商品信息</span></li>
					<li><span>单价</span></li>
					<li><span>数量</span></li>
					<li><span>金额</span></li>
					<li><span>操作</span></li>
				</ul>
			</div>
			<div class="product clear">
				<ul id="product_ul">
				
				<#if goodsList??>
					<#list goodsList as goods>
					<li>
						<div class="left">
							<div class="input">
								<img src="${ctx}/images/shop_car01.png" alt="0" id="input_${goods.id}"/>
								<img src="${ctx}/file/${goods.image}" alt="shop_cart01" style= "width:80px;height:80px;margin-top:18px;" />
							</div>
							<div class="detais">
								<p>
									<#if goods.title?length gt 20>
										${goods.title?substring(0,20)}
										<#else>
										${goods.title}
									</#if>
								</p>
								<img src="${ctx}/images/shop_cart02.jpg"/>
								<img src="${ctx}/images/shop_cart03.jpg"/>
								<img src="${ctx}/images/shop_cart04.jpg"/>
							</div>
							<div class="include">
								<span>净含量：1.8kg</span>
							</div>
						</div>	
						<div class="right">	
							<div class="price">
								¥<span id="price_1">${goods.favorablePrice}</span>
								<a href="#">促销&or;</a>
							</div>
							<div class="num">
								<a href="javascript:updateCar(${goods.id},1);" id="reduce">-</a>
								<input type="text" placeholder="1" id="buyNum" value="${goods.buyNum}" name="buyNum"/>
								<a href="javascript:updateCar(${goods.id},2);" id="add">+</a>
							</div>
							<div class="total">
								¥<span id="total_1">${goods.favorablePrice * goods.buyNum}</span>
							</div>
							<div class="del">
								<a href="#">移入收藏夹</a>
								<a href="${ctx}/customer/shopCar/delShopCar?goodsId=${goods.id}" id="del_1">删除</a>
							</div>
						</div>	
					</li>
					</#list>
				</#if>
					
				</ul>
			</div>
			<div class="accounts clear">
				<ul>
					<li>
						<a href="javascript:void(0)"  id="uncheck"><img src="${ctx}/images/shop_car01.png" alt="0"/>反选</a>
						
					</li>
					<li><a href="javascript:void(0);" id="delcheck">删除选中商品 </a></li>
					<li><a href="#">清空失效宝贝</a></li>
					<li><a href="#">移除收藏夹</a></li>
					<li><a href="#">分享</a></li>
					<li><a href="#">已选商品<span id="checkNum">0</span><img src="${ctx}/images/show_list04.png"/></a></li>
					<li>合计（不含运费）：<span id="total_price">0.00</span></li>
					<li><button type="submit" onclick="checkShopSum()"><a href="javascript:;" id="btnSubmit">结算</a></button></li>
				</ul>
			</div>
			<div class="buy clear" >
				<ol>
					<li>
						<span>失效</span>
						<a href="pro_details.html"><img src="${ctx}/images/shop_cart07.jpg"/></a>
					</li>
					<li>
						
						<p><a href="pro_details.html">强生婴儿香桃沐浴露1000ml滋润持久留香沐浴乳清洁全身家庭装适用</a></p>
						<img src="${ctx}/images/shop_cart02.jpg"/>
						<img src="${ctx}/images/shop_cart03.jpg"/>
						<img src="${ctx}/images/shop_cart04.jpg"/>
					</li>
					<li>
						<span>净含量：1kg</span>
					</li>
					<li>
						<span>¥69.0</span>
			
					</li>
					<li>
						
						<span>1</span>
						
					</li>
					<li>
						<span>¥39.0</span>
					</li>
					<li>
						<a href="#">移入收藏夹</a>
						<a href="#">删除</a>
						<a href="#">相似宝贝</a>
					</li>
				</ol>
			</div>
			<div class="hot clear">
				<div class="list clear">
					<ul>
						<li class="on"><a href="#">掌柜热卖</a></li>
						<li><a href="#">最近收藏</a></li>
						<li><a href="#">最近浏览过的</a></li>
						<li><a href="#">猜你喜欢的</a></li>
					</ul>
				</div>
				<div class="show clear">
					<div class="products">
						<ul>
							<li>
								<a href="pro_details.html"><img src="${ctx}/images/shop_cart08.jpg"/></a>
								<span>¥56.90</span>
								<p><a href="pro_details.html">强生婴儿活力清新沐浴露1000ml新生儿</a></p>
							</li>
							<li>
								<a href="pro_details.html"><img src="${ctx}/images/shop_cart09.jpg"/></a>
								<span>¥56.90</span>
								<p><a href="pro_details.html">巴斯克林 日本进口 舒芙蕾入浴液米乳</a></p>
							</li>
							<li>
								<a href="pro_details.html"><img src="${ctx}/images/shop_cart10.jpg"/></a>
								<span>¥56.90</span>
								<p><a href="pro_details.html">强生婴儿活力清新沐浴露1000ml新生儿</a></p>
							</li>
							<li>
								<a href="pro_details.html"><img src="${ctx}/images/shop_cart11.jpg"/></a>
								<span>¥56.90</span>
								<p><a href="pro_details.html">强生婴儿活力清新沐浴露1000ml新生儿</a></p>
							</li>
							<li>
								<a href="pro_details.html"><img src="${ctx}/images/shop_cart12.jpg"/></a>
								<span>¥56.90</span>
								<p><a href="pro_details.html">强生婴儿活力清新沐浴露1000ml新生儿</a></p>
							</li>
							
						</ul>
					</div>
				</div>
				
			</div>
		</div>
	
	</div>
	<!-- footer -->
	<#include "common/footer.html"/>
	<!-- footer end -->
</body>
</html>
